Skip to content

fix(shell): silence the shell model auto-import banner (docker + manual runs)#15234

Merged
blakeaowens merged 2 commits into
bugfixfrom
fix/reach-database-shell-no-imports
Jul 15, 2026
Merged

fix(shell): silence the shell model auto-import banner (docker + manual runs)#15234
blakeaowens merged 2 commits into
bugfixfrom
fix/reach-database-shell-no-imports

Conversation

@Maffooch

@Maffooch Maffooch commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What

Since Django 5.1, manage.py shell auto-imports every model on startup and prints a banner on every invocation:

36 objects could not be automatically imported:

  dojo.auditlog.services.ObjectsProductTags
  dojo.location.models.Tagulous_Location_tags
  pro.auditlog.RoleProxy
  ...

237 objects imported automatically (use -v 2 for details).

The "could not be imported" entries are dynamically-generated Tagulous tag models (Tagulous_*_tags) and auditlog proxy models — they exist on the app registry but aren't importable by their "<module>.<name>" path, so Django's auto-import can't resolve them. Nothing is actually wrong, but the list reads as an error.

This showed up in two places, both covered here:

1. Container startup scripts

docker/reach_database.sh (DB connectivity check) and docker/entrypoint-first-boot.sh (superuser creation) pipe short scripts into manage.py shell. They import exactly what they need, so they pass --no-imports (Django ≥ 5.2; the project pins 5.2.14) to skip auto-import entirely. The piped code still runs and exit codes are unchanged.

2. Manual manage.py shell runs

Developers running shell by hand won't pass --no-imports, so a dojo/management/commands/shell.py override filters get_auto_imports() down to paths that actually import. Real models still auto-import; the banner is clean. The filter is generic (it tries the import and keeps what succeeds), so it also covers Pro's proxy models without Pro needing its own override.

Testing

On Django 5.2.14:

  • reach_database.sh's connection test with --no-imports: banner gone, echo $? = 0.
  • Manual manage.py shell: prints only 237 objects imported automatically — no "could not be imported" list; Finding and other real models still auto-import.
  • unittests/test_shell_command.py (new): asserts every path returned by get_auto_imports() imports, that real models are kept, and that every dropped path is genuinely non-importable. Green.
  • ruff --config ruff.toml clean on the new files.

…t scripts

reach_database.sh and entrypoint-first-boot.sh pipe short scripts into
`manage.py shell` (a DB connectivity check and superuser creation). Since
Django 5.1 the shell command auto-imports every model on startup and prints
a banner like:

  36 objects could not be automatically imported:
    dojo.auditlog.services.ObjectsProductTags
    ...
  237 objects imported automatically (use -v 2 for details).

The "could not be imported" entries are dynamically-generated Tagulous tag
models and auditlog proxies that aren't importable by their dotted path, so
the list looks alarming on every container start even though nothing is
wrong. Both scripts import exactly what they need, so pass --no-imports
(Django >= 5.2) to skip the auto-import and drop the noise. The piped code
still runs and exit codes are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Maffooch Maffooch requested a review from blakeaowens as a code owner July 13, 2026 19:18
Manual `manage.py shell` runs still showed the auto-import failure banner
(the docker --no-imports change only covered the DB-reach / first-boot
scripts). Override the shell command's get_auto_imports() to keep only paths
that actually import, so dynamically-generated Tagulous tag models and
auditlog proxy models no longer appear as "could not be automatically
imported". Real models still auto-import; the filter is generic (tries the
import, keeps what succeeds) so it also covers Pro's proxy models.

Adds unittests/test_shell_command.py asserting every returned path imports,
real models are kept, and the dropped paths are all genuinely non-importable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Maffooch Maffooch changed the title fix(docker): silence shell auto-import banner in DB-reach / first-boot scripts fix(shell): silence the shell model auto-import banner (docker + manual runs) Jul 13, 2026
mtesauro
mtesauro previously approved these changes Jul 14, 2026

@mtesauro mtesauro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's going on with those tests

@mtesauro mtesauro dismissed their stale review July 14, 2026 01:13

When did these tests break? They showed green when I approved this...

@Maffooch Maffooch requested a review from Jino-T July 15, 2026 15:04
@Maffooch Maffooch added this to the 3.1.200 milestone Jul 15, 2026
@blakeaowens blakeaowens merged commit 21a7254 into bugfix Jul 15, 2026
274 of 277 checks passed
@blakeaowens blakeaowens deleted the fix/reach-database-shell-no-imports branch July 15, 2026 20:33
Maffooch added a commit that referenced this pull request Jul 15, 2026
* docs: redesign documentation site UI

Presentation-only redesign of docs.defectdojo.com. The rendered text of
all 612 pages is byte-identical to the previous build (verified by
diffing extracted page text across before/after builds); no content
files are touched.

Highlights:

- Token-based design system (CSS custom properties for light and dark)
  using the DefectDojo brand palette, with navy header and footer shared
  with trust.defectdojo.com
- Code blocks restyled as navy cards in both color modes by retheming
  the doks expressive-code frame variables: language labels in the
  header band, terminal dots for shell fences, styled copy button, and
  a brand-tuned Chroma syntax palette
- The Open Source / Pro version toggle is rebuilt from a select dropdown
  into an accessible segmented control (radiogroup semantics). Behavior
  is unchanged: same localStorage key and values, anti-flash reveal,
  edition-aware "Model Your Assets" nav link, and instances stay in sync
  across the desktop sidebar and mobile offcanvas
- Reading experience: 16px root font size (was 85 percent), 72ch measure,
  refined heading scale, framed screenshots, styled tables and callouts
- Mobile fixes: the header now shows the brand on small screens, and the
  offcanvas navigation actually opens. The site disables the full
  Bootstrap bundle (doks.bootstrapJavascript = false), so the offcanvas
  plugin never loaded and mobile nav buttons were dead on the live site;
  custom.js now imports just the Offcanvas plugin
- Homepage: navy hero with blueprint grid, prominent DocSearch trigger,
  quick-nav cards overlapping the hero edge; all copy unchanged

Note: netlify.toml pins HUGO_VERSION=0.125.1, which cannot build
doks-core 1.8.3 (it requires Hugo 0.146+ for layouts/_partials). The
production pipeline evidently uses a newer Hugo already; this change was
built and verified with Hugo 0.148.1 extended.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: fix active nav link contrast on navy header

The main nav row lives inside #offcanvasNavMain but outside
.offcanvas-body in this header, so the white active-link rule never
matched and the theme's Fuji Blue applied, which is hard to read on
the navy band. Scope the desktop rules to .navbar-nav directly (active
link is now white on a blue tint) and correct the mobile offcanvas
scope the same way (link blue on the light panel).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: remove baked-in canvas from dark-mode logo

The dark logo SVG is an auto-trace that carries its background as nine
opaque fill paths (#212529), invisible on the old dark-gray header but
visible as a box on the navy redesign. Delete the background paths and
recolor the seven letter counters and pixel notches to the navy surface
color so the wordmark renders clean in the header and footer.

Same fix as applied to the trust-center copy of this logo; the SVG is
still not truly transparent inside the letter counters, so reusing it on
non-navy backgrounds would need a proper even-odd hole merge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* stop os/pro switch flicker on page load

* docs: let hero search button take its accessible name from visible text

AccessLint flagged the label-in-name mismatch: aria-label said
"Search documentation" while the visible text says "Search the docs",
breaking voice-control activation. Drop the aria-label so the visible
label is the accessible name.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: fix sidebar clipping and focus-ring artifacts

The theme bleeds .docs-links 24px past its column (margin-right: -24px),
which pushed every sidebar item outside the version-menu scroll wrapper;
combined with the wrapper's overflow-x clipping, long labels, Pro
badges, and the active pill were cut off at the right edge. Zero the
bleed inside the wrapper and add slight right padding.

Also: clicked summaries keep :focus-visible in most browsers, and the
clipped outline ring rendered as stray horizontal lines around collapsed
groups in dark mode. Replace the ring with a filled focus state, and
ease group-label letter-spacing so long edition names wrap cleanly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: keep breadcrumbs on a single line

Bootstrap breadcrumbs prefix each crumb with its "/" separator, so when
the trail wrapped the separator dangled at the start of the next line.
Keep the trail on one line and ellipsize long crumbs instead: "Home"
never shrinks, ancestors compress to readable stubs, and the current
page keeps roughly twice the room. The active item renders as a block
because text-overflow does not draw an ellipsis on a flex container.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Update versions in application files

* docs: add Pro changelog entry for 3.1.100

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore(deps): bump django from 5.2.14 to 5.2.15 (#15230)

Bumps [django](https://github.com/django/django) from 5.2.14 to 5.2.15.
- [Commits](django/django@5.2.14...5.2.15)

---
updated-dependencies:
- dependency-name: django
  dependency-version: 5.2.15
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matt Tesauro <mtesauro@gmail.com>

* docs: add ServiceDesk Plus to the Pro Integrations tool reference (#15217)

Covers both editions (on-premises technician key and cloud Zoho OAuth
with the self-client walkthrough and regional token endpoints), the
group-name mapping identifier, priority/status name mappings, and the
SDP-specific behaviors (full content sync on update, close-on-delete,
mandatory-on-closure caveat).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>

* docs: add Zendesk to the Pro Integrations tool reference (#15215)

Covers instance setup (agent email + API token basic auth, subdomain
URL), the numeric group ID mapping identifier, priority and status
mappings, and the Zendesk-specific caveats (immutable description,
solve-on-delete, closed is terminal).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>

* feat(search): add DD_WATSON_SEARCH_ENABLED toggle to gate watson indexing (#15236)

Master switch (default True, so OSS behaviour is unchanged). When False: watson
models are not registered (no post-save index writes), the watson app +
AsyncSearchContextMiddleware are stripped from settings, /simple_search returns
410, and installwatson is skipped (both the complete_initialization command and
entrypoint-first-boot.sh).

Lets deployments that have replaced watson (e.g. DefectDojo Pro's native Postgres
search) stop paying the indexing cost and reclaim watson_searchentry.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* add OS Findings documentation (#15235)

* docs: use "DefectDojo, Inc." consistently in company name references (#15242)

Standardize every reference to the company name as "DefectDojo, Inc."
across the docs site content, config, and layout templates. Previously
the name appeared as "DefectDojo Inc" or "DefectDojo Inc." without the
comma. Possessive uses become "DefectDojo, Inc.'s".

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* fix(forms): avoid DB access at import time in Import/ReImport forms (#15233)

ImportScanForm and ReImportScanForm declared their finding-group fields
(group_by, create_finding_groups_for_all_findings) in the class body
guarded by is_finding_groups_enabled(). That helper reads a DB-backed
system setting, so merely importing dojo.forms issued a SELECT. When the
module is imported during app initialization (e.g. from an AppConfig
ready() hook), Django raises:

  RuntimeWarning: Accessing the database during app initialization is
  discouraged.

Move the conditional field construction into each form's __init__, so
importing the module never touches the database. Behavior is unchanged:
instances still gain the fields when finding groups are enabled, the
fields keep their original position (appended last), and the empty
default choice is still inserted. Evaluating the setting per-instance
instead of once at import is also more correct if the setting changes.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: add PagerDuty to the Pro Integrations tool reference (#15210)

Covers instance setup (REST API key, From user email, regional API base
URL), the service ID mapping identifier, the urgency vs account-priority
severity mapping modes, status mappings, and the PagerDuty-specific
caveats (resolved is final; title/body cannot be edited after creation).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>

* fix(shell): silence the shell model auto-import banner (docker + manual runs) (#15234)

* fix(docker): silence shell auto-import banner in DB-reach / first-boot scripts

reach_database.sh and entrypoint-first-boot.sh pipe short scripts into
`manage.py shell` (a DB connectivity check and superuser creation). Since
Django 5.1 the shell command auto-imports every model on startup and prints
a banner like:

  36 objects could not be automatically imported:
    dojo.auditlog.services.ObjectsProductTags
    ...
  237 objects imported automatically (use -v 2 for details).

The "could not be imported" entries are dynamically-generated Tagulous tag
models and auditlog proxies that aren't importable by their dotted path, so
the list looks alarming on every container start even though nothing is
wrong. Both scripts import exactly what they need, so pass --no-imports
(Django >= 5.2) to skip the auto-import and drop the noise. The piped code
still runs and exit codes are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(shell): drop non-importable models from shell auto-import

Manual `manage.py shell` runs still showed the auto-import failure banner
(the docker --no-imports change only covered the DB-reach / first-boot
scripts). Override the shell command's get_auto_imports() to keep only paths
that actually import, so dynamically-generated Tagulous tag models and
auditlog proxy models no longer appear as "could not be automatically
imported". Real models still auto-import; the filter is generic (tries the
import, keeps what succeeds) so it also covers Pro's proxy models.

Adds unittests/test_shell_command.py asserting every returned path imports,
real models are kept, and the dropped paths are all genuinely non-importable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Update versions in application files

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Greg Anderson <greg.anderson@owasp.org>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Paul Osinski <posinski34@gmail.com>
Co-authored-by: DefectDojo release bot <dojo-release-bot@users.noreply.github.com>
Co-authored-by: Ross E Esposito <ross@defectdojo.com>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
Co-authored-by: Paul Osinski <42211303+paulOsinski@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matt Tesauro <mtesauro@gmail.com>
Co-authored-by: Blake Owens <76979297+blakeaowens@users.noreply.github.com>
Co-authored-by: dangoelz <dangoelz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants